package controller;

import java.io.File;

import model.ConcreteBmpImage;
import model.Image;

/**
 * La classe ConcreteFactory à instance unique, va creer une object de type 
 * ConcreteBmpImage. 
 * 
 * @date 24-09-2014
 * @author Fredy A. Bonilla
 *
 */
public final class ConcreteFactory implements ImageFactory{
	
	/** Instance unique de la classe */
	private static volatile ConcreteFactory instance = null;
	
	/** Le contructeur de la classe est privée. */
	private ConcreteFactory() {};
	
	/**
	 * Creates a new instance of the ConcreteFactory class if none exist.
	 * @return The well-known instance of the Singleton class.
	 */
	public static ImageFactory getInstance() {
		if(instance == null)
			instance = new ConcreteFactory();
		return instance;
	}
	
	/*
	 * Methode implementée de l'interface ImageFactory
	 * @see controller.ImageFactory#build(java.io.File)
	 */
	public Image build(File file) {
		return new ConcreteBmpImage(file);
	}

}
